 //
//  ViewController.h
//  外星球生活圈
//
//  Created by MR.ZHOU on 15/8/12.
//  Copyright (c) 2015年 MR.ZHOU. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "AFHTTPSessionManager.h"
@protocol DSHTTPClientDelegate;

//成功回调
typedef void (^successBlock)(id data);
//失败的回调
typedef void (^failedBlock)(NSError *error);
//错误的回调
typedef void (^errorBlock)(id error);

@interface DSHTTPClient :AFHTTPSessionManager

//


@property(nonatomic,weak) id<DSHTTPClientDelegate> delegate;

+ (void)DSGET:(NSString *)url
    withParam:(NSDictionary *)param
    withDelegate:(id)delegate;



/*
    1.我们只需要开辟一块内存吧，
    2.很好的管理我们的网络请求
 */

//创建网络请求的单例
+ (DSHTTPClient *)shareInatance;

/**
 *  Get请求
 *
 *  @param url     url
 *  @param param   请求参数
 *  @param success 成功的回调
 *  @param failed  失败的回调
 *  @param error   请求成功，但是有错误信息的回调
 */
+ (void)DSGET:(NSString *)url
    withParam:(NSDictionary *)param
withSuccessBlock:(successBlock)success
withFailedBlock:(failedBlock)failed
withErrorBlock:(errorBlock)error;

/**
 *  Post请求
 *
 *  @param url     url
 *  @param param   请求参数
 *  @param success 成功的回调
 *  @param failed  失败的回调
 *  @param error   请求成功，但是有错误信息的回调
 */
+ (void)DSPOST:(NSString *)url
    withParam:(NSDictionary *)param
withSuccessBlock:(successBlock)success
withFailedBlock:(failedBlock)failed
withErrorBlock:(errorBlock)error;

@end

@protocol DSHTTPClientDelegate <NSObject>


//请求成功的回调
- (void)didSuccessRequest:(id)data;
//请求失败的回调
- (void)didFailedRequest:(id)failed;
//请求错误的回调
- (void)didErrorRequest:(id)error;

@end
